/*
 * The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
 * 
 * Find the sum of all the primes below two million.
 */
package pj1;

class Problem10 {

	static final int problem = 2000000;
	
	//checks whether an int is prime or not.
	private static boolean isPrime(int num)
	{
		boolean prime = true;
		int limit = (int)Math.sqrt(num);  
		for(int i=2; i <= limit; i++) {
			if(num%i == 0) {
				prime = false;
				break;
			}
		}
		return prime;
	}
	
	public static void main(String[] args) {
		int n = 2;
		long i = 0;
		while (n < problem) {
			if (isPrime(n)) {
				i+=n;
			}
			n++;
		}
		System.out.println(i);
	}

}
